﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using System.Web;
using System.Windows.Forms;
using System.Diagnostics;

namespace SkyDriveLib
{
    class TestClass
    {

        static void Main()
        {

            SkyDriveLib sky = new SkyDriveLib();

            //sky.connect("key");

            //UserObj user;
            //string x = sky.connect("key");
            //string user = sky.getUserDetail();
            /*Console.WriteLine(user.Id);
            Console.WriteLine(user.Name);
            Console.WriteLine(user.FirstName);
            Console.WriteLine(user.LastName);
            Console.WriteLine(user.Gender);
            Console.WriteLine(user.Locale);
            */
            //Console.WriteLine (user);



            var uri = "https://login.live.com/oauth20_authorize.srf";

            var authorizeUri = new StringBuilder(uri);
            StringBuilder auth = new StringBuilder();
            authorizeUri.AppendFormat("?client_id={0}&", "key");
            authorizeUri.AppendFormat("scope={0}&", "wl.signin");
            authorizeUri.AppendFormat("response_type={0}&", "token");
            authorizeUri.AppendFormat("redirect_uri={0}", HttpUtility.UrlEncode("http://paulonicolau.eu/"));

            //auth.AppendFormat("?client_id={0}&", ClientID);
            //auth.AppendFormat("scope={0}&", "wl.signin");
            //auth.AppendFormat("response_type={0}&", "token");
            //auth.AppendFormat("redirect_uri={0}", HttpUtility.UrlEncode("http://paulonicolau.eu/"));

            /* var startInfo = new ProcessStartInfo();
             startInfo.FileName = authorizeUri.ToString();
             Process.Start(startInfo);
             */
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(authorizeUri.ToString());
            request.AllowAutoRedirect = true;
            
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();
            request.Accept = "text/plain";
            Console.WriteLine( request.Address);
           
            
                

            

            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
    }
}
